<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>青芽医疗管理平台</title>
    <meta name="description" content="数据采集分析系统">
    <meta name="keywords" content="数据采集分析系统">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
</head>
<body class="hold-transition">

<div id="app">
    <div class="filter-container">
        <el-input placeholder="患者名称" style="width: 200px;" class="filter-item" v-model="pagination.queryName"></el-input>
        <el-select clearable="true" placeholder="用户" v-model="pagination.userId">
            <el-option
                    :key="item.userId"
                    :label="item.name"
                    :value="item.userId"
                    v-for="item in userList">
            </el-option>
        </el-select>
        <el-select clearable="true" placeholder="科室" v-model="pagination.departmentId">
            <el-option
                    :key="item.departmentId"
                    :label="item.departmentName"
                    :value="item.departmentId"
                    v-for="item in departmentList">
            </el-option>
        </el-select>
        <el-select clearable="true" placeholder="房间" v-model="pagination.roomId">
            <el-option
                    :key="item.roomId"
                    :label="item.roomNumber"
                    :value="item.roomId"
                    v-for="item in roomList">
            </el-option>
        </el-select>
        <el-button @click="_getRegisteredOrderPage()" class="dalfBut">查询</el-button>
    </div>

    <el-table size="small" current-row-key="registeredOrderId" :data="list" stripe highlight-current-row>
        <el-table-column type="index" align="center" label="序号"></el-table-column>
        <el-table-column prop="patientName" label="患者名称" align="center"></el-table-column>
        <el-table-column prop="departmentName" label="科室名称" align="center"></el-table-column>
        <el-table-column prop="name" label="医生名称" align="center"></el-table-column>
        <el-table-column prop="roomNumber" label="房间名称" align="center"></el-table-column>
        <el-table-column prop="roomAddress" label="房间地址" align="center"></el-table-column>
        <el-table-column prop="registeredFree" label="挂号费" align="center"></el-table-column>
        <el-table-column prop="formatRegisteredTime" label="挂号时间" align="center"></el-table-column>
        <el-table-column prop="formatReserveInquiryTime" label="预约问诊时间" align="center"></el-table-column>
        <el-table-column prop="formatCreateTime" label="挂号单创建时间" align="center"></el-table-column>
        <el-table-column prop="registeredStatus" label="挂号单状态" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
            <template slot-scope="scope">
                <el-button size="mini" type="danger" @click="delRegisteredOrder(scope.row)">删除</el-button>
            </template>
        </el-table-column>
    </el-table>
    <div class="pagination-container">
        <el-pagination
                class="pagiantion"
                @current-change="handleCurrentChange"
                :current-page="pagination.currentPage"
                :page-size="pagination.pageSize"
                layout="total, prev, pager, next, jumper"
                :total="pagination.total">
        </el-pagination>
    </div>

</div>

</body>
<!-- 引入组件库 -->
<script src="js/vue.js"></script>
<script src="element-ui/lib/index.js"></script>
<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
<script src="js/axios-0.18.0.js"></script>
<script type="application/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize:10,//每页显示的记录数
                total:0,//总记录数
                queryString:null//查询条件
            },
            list:[],
            departmentList:[],
            userList:[],
            roomList:[]
        },
        mounted () {
           this.getRegisteredOrderPage();
        },
        methods: {
            _getRegisteredOrderPage() {
                this.pagination.currentPage = 1;
                this.getRegisteredOrderPage();
            },
            handleCurrentChange(currentPage){
                this.pagination.currentPage = currentPage;
                this.getRegisteredOrderPage();
            },
            getRegisteredOrderPage() {
                //发送ajax请求，提交分页相关请求参数（页码、每页显示记录数、查询条件）
                var queryPageBean = {
                    currentPage: this.pagination.currentPage,
                    pageSize: this.pagination.pageSize,
                    queryTerm: {
                        patientName: this.pagination.queryName,
                        departmentId: this.pagination.departmentId,
                        userId: this.pagination.userId,
                        roomId: this.pagination.roomId
                    }
                };
                axios.post("/registeredOrder/getRegisteredOrderPage", "queryPageBean=" + JSON.stringify(queryPageBean)).then((res) => {
                    this.list = res.data.list;
                    this.pagination.total = res.data.total;
                });
                axios.post("/department/getDepartmentList",).then((res) => {
                    this.departmentList = res.data;
                });
                axios.post("/user/getUserByDepartmentId?departmentId=&userId=",).then((res) => {
                    this.userList = res.data;
                });
                axios.post("/room/getRoomByDepartmentId?departmentId=&roomId=",).then((res) => {
                    this.roomList = res.data;
                });
            },
            delRegisteredOrder(row){
                this.$confirm("你确定要删除当前数据吗？","提示",{//确认框
                    type:'warning'
                }).then(()=>{
                    //用户点击确定按钮，发送ajax请求，将检查项ID提交到Controller进行处理
                    axios.post("/registeredOrder/delRegisteredOrder","registeredOrder="+JSON.stringify(row)).then((res) => {
                        if(res.data){
                            //执行成功
                            //弹出成功提示信息
                            this.$message({
                                type:'success',
                                message:"删除成功"
                            });
                            //重新进行分页查询
                            this.getUserPage();
                        }else{
                            //执行失败
                            this.$message.error("删除失败");
                        }
                    }).catch((r)=>{
                        this.showMessage(r);
                    });
                }).catch(()=>{
                    this.$message({
                        type:'info',
                        message:'操作已取消'
                    });
                });
            }
        }
    })
</script>
</html>